package vista;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.util.Observable;
import java.util.Observer;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;

import model.ModeloObsrvable;

public class VistaPanel1 extends JPanel implements Observer {

	private static final long serialVersionUID = -597561876554270720L;
	private ModeloObsrvable modelo;

	public VistaPanel1(ModeloObsrvable modelo) {
		this.modelo = modelo;
		this.modelo.addObserver(this);
		setBounds(10, 11, 650, 480);
		setBackground(Color.black);
		//setLayout(null);
		setLayout(new BorderLayout(0, 0));
	}

	@Override
	public void update(Observable arg0, Object arg1) {
		removeAll();
		repaint();

	}
	
	public void paintComponent(Graphics grafico) {

        super.paintComponent(grafico);
/*P1*/	
        JLabel label = new JLabel();
		//label.setBounds(0, 0, 650, 324);
		label.setIcon(new ImageIcon(VistaPanel1.class.getResource("/vista/ciudades/"+ modelo.getPoliciaCiudadActual() +".jpg")));
		/*BufferedImage image = null;
		try {
			try {
				image = ImageIO.read(new File(VistaPanel1.class.getResource("/vista/ciudades/"+ modelo.getPoliciaCiudadActual() +".jpg").toURI()));
			} catch (URISyntaxException e) {
				e.printStackTrace();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		*/
		add(label, BorderLayout.NORTH);
		//grafico.drawImage(image, 0, 0, null);
		
		JTextPane textDescImagen = new JTextPane();
		textDescImagen.setBackground(Color.LIGHT_GRAY);
		textDescImagen.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 18));
		textDescImagen.setText("Ciudad Actual: " + modelo.getPoliciaCiudadActual() + "\n" + modelo.getPoliciaDescripcionCiudadActual());
		textDescImagen.setEditable(false);
		//textDescImagen.setBounds(0, 324, 650, 156);
		add(textDescImagen, BorderLayout.CENTER);
		
	}

}
